package com.gimi.cloud.bbp.dao.dao.sys;

import com.gimi.cloud.bbp.dao.myMapper.core.query.QueryParam;
import com.gimi.cloud.bbp.dao.myMapper.core.query.QueryParamProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * 基础封装查询参数
 * @param <T>  Entity类型
 * @param <K>  DTO类型
 */
@Mapper
public interface BaseDao<T,K> {

    /**
     * 查询返回List<Map<String,Object>>
     * @param param
     * @return
     */
    @SelectProvider(type = QueryParamProvider.class, method = "selectListBySql")
    List<Map<String,Object>> selectListBySql(QueryParam param);

    /**
     * 查询返回List<T>
     * @param param 查询参数
     * @return 查询结果 Entity
     */
    @SelectProvider(type = QueryParamProvider.class, method = "selectListBySql")
    List<T> selectListEntityBySql(QueryParam param);
    /**
     * 查询返回List<T>
     * @param param 查询参数
     * @return  查询结果DTO
     */
    @SelectProvider(type = QueryParamProvider.class, method = "selectListBySql")
    List<K> selectListDTOBySql(QueryParam param);

    /**
     * 查询返回单条记录
     * @param param
     * @return
     */
    @SelectProvider(type = QueryParamProvider.class, method = "selectOneBySql")
    Map<String,Object> selectOneBySql(QueryParam param);

    /**
     * 查询返回单条记录
     * @param param 查询参数
     * @return  Entity类型
     */
    @SelectProvider(type = QueryParamProvider.class, method = "selectOneBySql")
    T selectOneEntityBySql(QueryParam param);

    /**
     * 查询返回单条记录
     * @param param 查询参数
     * @return DTO类型
     */
    @SelectProvider(type = QueryParamProvider.class, method = "selectOneBySql")
    K selectOneDTOBySql(QueryParam param);

    /**
     * 查询获取行数
     * @param param
     * @return
     */
    @SelectProvider(type = QueryParamProvider.class, method = "selectCountBySql")
    Integer selectCountBySql(QueryParam param);

    /**
     * 分页查询
     * @param param
     * @return
     */
    /*
    @SelectProvider(type = QueryParamProvider.class, method = "pageListBySql")
    List<Map<String,Object>> pageListBySql(QueryParam param);
    */

    /**
     * sql更新
     * @param param
     * @return
     */
    @UpdateProvider(type = QueryParamProvider.class, method = "updateSql")
    Integer updateSql(QueryParam param);

    /**
     * sql更新
     * @param param
     * @return
     */
    @DeleteProvider(type = QueryParamProvider.class, method = "deleteSql")
    Integer deleteSql(QueryParam param);
}
